class LivesController < ApplicationController
  before_filter :login_required , :except => [:index, :show]
  # GET /lives
  # GET /lives.xml
  def index
    @lives = Live.find(:all)

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @lives }
    end
  end

  # GET /lives/1
  # GET /lives/1.xml
  def show
    @live = Live.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @live }
    end
  end

  # GET /lives/new
  # GET /lives/new.xml
  def new
    @live = Live.new

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @live }
    end
  end

  # GET /lives/1/edit
  def edit
    @live = Live.find(params[:id])
  end

  # POST /lives
  # POST /lives.xml
  def create
    @live = Live.new(params[:live])

    respond_to do |format|
      if @live.save
        flash[:notice] = 'Live was successfully created.'
        #format.html { redirect_to(@live) }
        format.html { redirect_to :controller => "lives" }
        format.xml  { render :xml => @live, :status => :created, :location => @live }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @live.errors, :status => :unprocessable_entity }
      end
    end
  end

  # PUT /lives/1
  # PUT /lives/1.xml
  def update
    @live = Live.find(params[:id])

    respond_to do |format|
      if @live.update_attributes(params[:live])
        flash[:notice] = 'Live was successfully updated.'
        format.html { redirect_to(@live) }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @live.errors, :status => :unprocessable_entity }
      end
    end
  end

  # DELETE /lives/1
  # DELETE /lives/1.xml
  def destroy
    @live = Live.find(params[:id])
    @live.destroy

    respond_to do |format|
      format.html { redirect_to(lives_url) }
      format.xml  { head :ok }
    end
  end
end
